package xdu.lz.stage2_design_pattern.chapter2_single_pattern;

public class Singleton5 {

    private Singleton5(){

    }

    //利用了枚举的构造函数只会被创建一次
    private enum Single{
        //Single.INSTANCE是枚举类的一个实例
//        Single instance = Single.INSTANCE;
        INSTANCE;

        private final Singleton5 instance;

        Single(){
            instance = new Singleton5();
        }

        public Singleton5 getInstance() {
            return instance;
        }
    }

    public static Singleton5 getInstance(){

        return Single.INSTANCE.getInstance();
    }
}
